package org.jeecg.modules.hc.enums;

import java.util.Arrays;
import java.util.Optional;

public enum HcWxPayStateEnum {
    SUCCESS("SUCCESS", "支付成功"),
    REFUND("REFUND", "转入退款"),
    NOTPAY("NOTPAY", "未支付"),
    CLOSED("CLOSED", "已关闭"),
    REVOKED("REVOKED", "已撤销（仅付款码支付会返回）"),
    USERPAYING("USERPAYING", "用户支付中（仅付款码支付会返回）"),
    PAYERROR("PAYERROR", "支付失败（仅付款码支付会返回）"),
    ;

    private String value;
    private String name;

    public static String get(String val) {
        Optional<HcWxPayStateEnum> first = Arrays.stream(HcWxPayStateEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        return first.map(HcWxPayStateEnum::getName).orElse(null);
    }

    public static HcWxPayStateEnum getEnum(String val) {
        Optional<HcWxPayStateEnum> first = Arrays.stream(HcWxPayStateEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        return first.orElse(null);
    }

    HcWxPayStateEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
